package com.moogene.saad.gameplay.bullet;

import java.util.ArrayList;
import java.util.HashMap;

import com.moogene.android.R;
import com.moogene.android.engine.animlite.Animlite;
import com.moogene.saad.gameplay.attacter.Attacker;

public abstract class Physics {
	private static HashMap<Integer, String> bulletPhysics;
	protected Bullet bullet;
	protected Attacker target;
	
	public static void load(String name){
		bulletPhysics = new HashMap<Integer, String>();
		if(name.equalsIgnoreCase("level1")){
			bulletPhysics.put(R.drawable.bullet_flysword, "com.moogene.saad.gameplay.bullet.LaserPhysics");
		}
	}
	public static Physics getPhysics(Animlite anim, Bullet b){
		Physics p = null;
		if(anim == null){
			p = new InvisiblePhysics();
			p.init(b);
			return p;
		}
		String physicsClassName = bulletPhysics.get(anim.getResId());
		try {
			p = (Physics) Class.forName(physicsClassName).newInstance();
			p.init(b);
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return p;
	}
	
	private void init(Bullet bullet){
		this.bullet = bullet;
	}
	
	public void shoot(Attacker attacker){
		this.target = attacker;
	}
	public abstract ArrayList<Attacker> updateAndGetBingos();
}
